"use strict";

(function() {
	alx.svg.Polyline = function (svgArgs) {
		var me       = this,
				svgPoly  = null,
				points   = "";
				
		var init = function() {
			svgPoly = document.createElementNS(alx.svg.ns, "polyline");
			alx.svg.setAttributeMap(svgArgs, svgPoly);	
		};
		
		me.getElement = function () {
			return svgPoly;
		};
		
		me.addPoint = function (p) {
			if (points.length > 0) points += " ";
			points += " " + p.x + "," + p.y;
			
			refreshPoints();
		};
		
		me.clear = function() {
			points = "";
			refreshPoints("");
		};
		
		// Private stuff
		var refreshPoints = function() {
			svgPoly && svgPoly.setAttribute("points", points);
		};
		
		// ------------------------------------------------------------- //
		init();
	};
})();